package module;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import bean.Order;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;

import DateBase.Datebase;

public class OrderModule {
	Datebase con=new Datebase();
	Connection conn=(Connection) con.getConnection();
	public ArrayList getOrderMsg(int userid) throws SQLException{
		ArrayList list=new ArrayList();
		Statement st=(Statement) conn.createStatement();
		String sql="select * from ordermsg where userid="+userid+"";
		ResultSet rs=st.executeQuery(sql);
		while(rs.next()){
			Order order=new Order();
			order.setOrderid(rs.getInt("orderid"));
			order.setOrdernum(rs.getInt("ordernum"));
			order.setOrdertime(rs.getString("ordertime"));
			order.setPrice(rs.getFloat("price"));
			order.setSta(rs.getInt("sta"));
			list.add(order);
		}
		return list;
	}
}
